package com.wancaijinfu.parse;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.wancaijinfu.javabean.Borrow;
import com.wancaijinfu.javabean.PageData;

public class BorrowListParse  extends PostParse{

	
	@Override
	public Object parseSuccess(JSONObject object) throws JSONException {
		PageData data = new PageData();
		if (object.has("lastPage"))
			data.isLast = object.getBoolean("lastPage");
		JSONArray borrowlist = object.getJSONArray("list");
		List<Borrow> list = new ArrayList<Borrow>();
		for (int i = 0; i < borrowlist.length(); i++) {
			JSONObject newObj = borrowlist.getJSONObject(i);
			Borrow item = new Borrow();
			item.id = newObj.getString("id");
			item.account =  newObj.getDouble("account");
			item.name =  newObj.getString("name");
			item.time_limit =  newObj.getInt("time_limit");
			item.lowest_account =  newObj.getString("lowest_account");
			item.most_account =  newObj.getString("most_account");
			item.valid_time =  newObj.getString("verify_time3");
			item.status =  newObj.getString("status");
			item.tender_times =  newObj.getString("tender_times");
			item.end_time =  newObj.getString("end_time");
			item.apr =  newObj.getDouble("apr");
			item.account_yes =  newObj.getDouble("account_yes");
			item.is_day =  newObj.getInt("is_day");
			item.award =  newObj.getInt("award");
			item.funds =  newObj.getDouble("funds");
			item.part_account =  newObj.getDouble("part_account");
			
			list.add(item);
		}
		data.datas = list;
		return data;
	}

	

}
